import {showModal} from "../actions/modal.action"
import { SHOWMODAL_ASYNC } from "../const.js/modal.const"
import { takeEvery, put, delay } from 'redux-saga/effects'

// takeEvery 接收action
// put 触发action

function *showModal_async_fn() {
    yield delay(2000)
    yield put(showModal())
}

// redux-saga 独立出来的函数 默认返回一个generator函数
// 里面takeEvery接收action  第一个参数为要执行的action名称的字符串  第二个参数为要触发actioin函数
export default function *counterSaga() {
    yield takeEvery(SHOWMODAL_ASYNC, showModal_async_fn)
}